package com.yunsom.testdemo.multiple_thread.create_functions;

/**
 * @author Xbao
 * @description
 * @date 2022/5/10 10:17
 */
public class ImplementsRunnableTest implements Runnable{

  private int i;

  @Override
  public void run() {
    for (i = 0; i < 100; i++) {
      System.out.println(Thread.currentThread().getName() + " " + i);
    }
  }

  public static void main(String[] args) {
    for (int i = 0; i < 100; i++) {
      System.out.println(Thread.currentThread().getName() + " " + i);
      if (i == 20){
        ImplementsRunnableTest runnableThread = new ImplementsRunnableTest();
        new Thread(runnableThread, "新线程1").start();
        new Thread(runnableThread, "新线程2").start();
      }
    }
  }

}
